package com.dz.generator.util;

import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author 梁建军
 * 创建日期： 2019/9/4
 * 创建时间： 11:00
 * @version 1.0
 * @since 1.0
 */
public class StringBootResourceLoader extends StringResourceLoader {


    @Override
    public InputStream getResourceStream(String name) throws ResourceNotFoundException {
        Resource resource = new ClassPathResource(name);

        try {
            return resource.getInputStream();
        } catch (IOException e) {
            throw new ResourceNotFoundException(e);
        }

    }
}
